//
//  BaseViewController.swift
//  DouYuZB
//
//  Created by 梁森 on 2020/4/21.
//  Copyright © 2020 梁森. All rights reserved.
//

import UIKit

class BaseViewController: UIViewController {

    var contentView:UIView?
    lazy var animationView:UIImageView = { [unowned self] in
        let animationView = UIImageView()
        animationView.image = UIImage(named: "img_loading_1")
        animationView.animationImages = [UIImage(named: "img_loading_1")!, UIImage(named: "img_loading_2")!]
        animationView.animationDuration = 0.5
        animationView.animationRepeatCount = LONG_MAX
        return animationView
    }()
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.white
        setupUI()
    }
    

}

extension BaseViewController{
    @objc func setupUI() {
        contentView?.isHidden = true
        animationView.startAnimating()
        view.addSubview(animationView)
        animationView.snp.makeConstraints { (make) in
            make.centerX.equalTo(self.view.snp.centerX)
            make.centerY.equalTo(self.view.snp.centerY)
        }
    }
    
    @objc func requestDataFinish(){
        animationView.stopAnimating()
        animationView.isHidden = true
        contentView?.isHidden = false
    }
}
